<?php
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/AW-LICENSE.txt
 *
 * =================================================================
 *                 MAGENTO EDITION USAGE NOTICE
 * =================================================================
 * This package designed for Magento community edition
 * aheadWorks does not guarantee correct work of this extension
 * on any other Magento edition except Magento community edition.
 * aheadWorks does not provide extension support in case of
 * incorrect edition usage.
 * =================================================================
 *
 * @category   AW
 * @package    AW_Blog
 * @version    1.2.1
 * @copyright  Copyright (c) 2010-2012 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/AW-LICENSE.txt
 */
?><?php $post = $this->getPost(); 
$comments = $this->getComment();
$countcmt=0;
?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<div id="blog-detail">
	<div class="page-title category-title">
		<h1><?php echo $this->__('Our Blog');?></h1>
	</div>
	<div class="inner-post-wrapper">
		<div class="detail-blog-post">
			<div class="postWrapper">
				<div class="postTitle">
					<h2><?php echo $post->getTitle(); ?></h2>
					<h3><?php echo $post->getCreatedTime(); ?></h3>
					<!--
					<div class="info-cat-blog postDetails">
						<?php $postCats = $post->getCats(); ?>
						<?php if (!empty($postCats)): ?>
							<?php echo Mage::helper('blog')->__('Category:'); ?>
							<?php foreach ($postCats as $title => $url): ?>
								<a class="cat-title" href="<?php echo $url; ?>"><?php echo $title; ?></a> 
							<?php endforeach; ?> 
						<?php else: ?>
							<?php echo Mage::helper('blog')->__('Posted'); ?>
						<?php endif; ?><?php echo $this->__("Written by:"); ?> <span class="user-wr"><?php echo $post->getUser(); ?></span>
					</div>
					-->
					<!--<h3><?php echo $post->getCreatedTime(); ?></h3>-->
				</div>
				<!--
				<div class="image-blog-post">
					<img title="<?php echo $post->getTitle();?>" alt="<?php echo $post->getTitle();?>" src="<?php echo  Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$post->getPostImage();?>"> 
				</div>
				-->
				<div class="postContent"><?php echo $post->getPostContent(); ?></div>
				<?php echo $this->getBookmarkHtml($post) ?>
				<div class="tags"><?php echo Mage::getBlockSingleton('blog/blog')->getTagsHtml($post) ?></div>
				
			</div>
		</div>
	<!-- Comment Section -->

	<?php if ($this->getCommentsEnabled()): ?>

		<form action="" id="postComment" method="post">
					<fieldset class="group-select">
						<!--<h4 class="legend"><?php echo Mage::helper('blog')->__('Submit Comment') ?></h4>-->
						<ul class="form-list">
							<li>
								<div class="input-box name-blog-input">
									<!--<label for="name" class="required"><?php echo Mage::helper('blog')->__('Name (Required): ') ?></label>-->
									<input placeholder="Your name:" name="user" id="user" value="<?php echo $this->getCommentName(); ?>" title="<?php echo $this->__('Name') ?>" class="required-entry input-text" type="text" />
								</div>

								<div class="input-box email-blog-input">
									<!--<label for="email" class="required"><?php echo Mage::helper('blog')->__('Email (Required):') ?></label>-->
									<input placeholder="Your email:" name="email" id="email" value="<?php echo $this->getCommentEmail(); ?>" title="<?php echo $this->__('Email') ?>" class="required-entry input-text validate-email" type="text" />
								</div>

								<div class="clear"></div>

								<div class="input-box aw-blog-comment-area">
									<!--<label for="comment" class="required"><?php echo Mage::helper('blog')->__('Comment') ?><em>*</em></label><br />-->
									<textarea placeholder="Comment:" name="comment" id="comment" title="<?php echo Mage::helper('blog')->__('Comment') ?>" class="required-entry input-text" style="height:150px;width:100%;" cols="50" rows="5"><?php echo $this->getCommentText(); ?></textarea>
								</div>
							</li>

							<?php
							if (Mage::getStoreConfig('blog/recaptcha/enabled') && !$this->helper('customer')->isLoggedIn()) {
								?><li><?php
					require_once 'recaptcha/recaptchalib-aw.php';

					// Get a key from http://recaptcha.net/api/getkey
					$publickey = Mage::getStoreConfig('blog/recaptcha/publickey');
					$privatekey = Mage::getStoreConfig('blog/recaptcha/privatekey');
					$error = null;

					echo recaptcha_get_html($publickey, $error);
								?></li><?php
				}
							?>                        
						</ul>
					</fieldset>
					<div class="button-set" style="">
						<input name="post_id" type="hidden" value="<?php echo $post->getPostId(); ?>" />
						<!--<p class="required"><?php echo $this->__('* Required Fields') ?></p>-->
						<button title="<?php echo $this->__('Submit Comment')?>" class="button form-button" type="submit"><span><span><?php echo Mage::helper('blog')->__('Comment') ?></span></span></button>
					</div>
		</form>
		<?php if ($this->getCommentsEnabled()): ?>
			<?php
				foreach ($comments as $comment) : 
					$countcmt++;
				endforeach;
				//echo $countcmt;
			?>
			<div class="comment-blog comment-blog-count">
				<a class="link-comment" ><?php echo $countcmt; ?> <?php if($countcmt<=1) echo $this->__('Comment'); ?>  <?php if($countcmt>1) echo $this->__('Comments'); ?></a>
			</div>
		<?php endif; ?>
		<?php $comments = $this->getComment(); ?>
		

		<?php //echo $this->getChildHtml('aw_blog_comments_toolbar'); ?>
			<?php foreach ($comments as $comment) : ?>
				<div class="commentWrapper">
					<div class="commentDetails"><h4 class="username"><?php echo $comment->getUser(); ?></h4> </div>
					<div class="commentContent"><?php echo nl2br($comment->getComment()); ?></div>
					<div class="date-post"><?php echo $this->formatDate($comment->getCreatedTime(), Mage::getStoreConfig('blog/blog/dateformat'), true); ?></div>
				</div>       
			<?php endforeach; ?>
		 <?php echo $this->getChildHtml('aw_blog_comments_toolbar'); ?>
	 

		<?php if ($post->getComments()): ?>
			<div class="postError"><?php echo Mage::helper('blog')->__('Comments are Closed for this post') ?></div>
		<?php else: ?>
			<?php if ($this->getLoginRequired()): ?>
				<?php if ($this->helper('customer')->isLoggedIn()): ?>
					<form action="" id="postComment" method="post">  
						<fieldset class="group-select">
							<h4 class="legend"><?php echo Mage::helper('blog')->__('Submit Comment') ?></h4>
							<ul class="form-list">
								<li>

									<div class="input-box aw-blog-comment-area">
										<label for="comment" class="required"><?php echo Mage::helper('blog')->__('Comment') ?><em>*</em></label><br />
										<textarea name="comment" id="comment" title="<?php echo $this->__('Comment') ?>" class="required-entry input-text" style="height:150px;width:95%;" cols="50" rows="5"><?php echo $this->getCommentText(); ?></textarea>
									</div>
								</li>
							</ul>
						</fieldset>
						<div class="button-set" style="">
							<input name="post_id" type="hidden" value="<?php echo $post->getPostId(); ?>" />
							<input name="email" type="hidden" value="<?php echo $this->htmlEscape($this->helper('blog')->getUserEmail()) ?>"/>
							<input name="user" type="hidden" value="<?php echo $this->htmlEscape($this->helper('blog')->getUserName()) ?>"/>
							<p class="required"><?php echo $this->__('* Required Fields') ?></p>
							<button class="form-button button" type="submit"><span><span><?php echo Mage::helper('blog')->__('Submit Comment') ?></span></span></button>
						</div>
					</form>
					<script type="text/javascript">
						var contactForm = new VarienForm('postComment', false);
					</script>            

				<?php else: ?>
					<p><?php echo Mage::helper('blog')->__('You must be logged in to post a comment.'); ?></p>
					<p><a href="<?php echo Mage::helper('customer')->getLoginUrl(); ?>"><?php echo Mage::helper('blog')->__('click here'); ?></a> <?php echo Mage::helper('blog')->__('to log in'); ?></p>
				<?php endif ?>

			<?php else: ?>

				

				<script type="text/javascript">
					var contactForm = new VarienForm('postComment', false);
				</script>
			<?php endif; ?>
		<?php endif; ?>
	<?php endif; ?>
	</div>
</div>